package com.itheima.tlias84.mapper;

import com.itheima.tlias84.annotaion.ReportLog;
import com.itheima.tlias84.dto.SelectEmpDTO;
import com.itheima.tlias84.dto.SelectEmpDetailDTO;
import com.itheima.tlias84.entity.Emp;
import com.itheima.tlias84.po.InsertEmpParam;
import com.itheima.tlias84.po.SelectEmpPageParam;
import com.itheima.tlias84.po.updateEmpParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 都是标识Dao层的注解
 * @Mapper  ->mybatis 提供
 * @Repository  -> springboot 提供
 */
//@Repository
@Mapper
public interface EmpMapper {

    //查询员工
    List<SelectEmpDTO> selectEmpByPage(@Param("p")SelectEmpPageParam param);
    @ReportLog
    //批量删除
    int delectEmpById(@Param("ids") List<Integer> ids);
    @ReportLog
    //添加员工
    int insertEmp(@Param("p") InsertEmpParam param);
   @ReportLog
    //修改员工
    int updateEmp(@Param("p") updateEmpParam param);

    //根据id查询
    SelectEmpDetailDTO selectEmpById(@Param("id") Integer id);

    //查询所有员工
    @Select("select * from emp where job=1")
    List<SelectEmpDTO> selectEmpList();

    //用户登录
    @Select("select id,username,password,name from emp where username=#{username}")
    Emp selectEmpByUsername(@Param("username")String userName);

    //计算职位人数
    @Select("select job as count from emp")
    List<Integer> empJobData(); //通过查询所有人的职位
}
